package com.candy.control;

import com.alibaba.fastjson2.JSON;
import com.candy.service.UserInfoManagerService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.LinkedList;

@WebServlet("/getUserInfo")
public class GetSudentByAjaxServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//       调用业务逻辑处理层，用户用户表中的所有数据
        UserInfoManagerService service=new UserInfoManagerService();
        LinkedList<LinkedHashMap<String,Object>> userinfoes= service.getUserInfoes();
//   将数据进行转换为JSON字符串
        String userinfoesStr=JSON.toJSONString(userinfoes);
        resp.getWriter().println(userinfoesStr);
    }
}
